package reader;

import java.io.*;

/**
 * @author 王艺锡
 * @version 1.0
 * 转换流
 * Reader的子类
 * InputStreamReader可以将InputStream字节流包装成Reader字符流
 * 用于解决中文乱码的问题
 */
public class InputStreamReader_ {
    public static void main(String[] args) throws IOException {
//        String filePath = "e:\\hello.txt";
//        BufferedReader br = new BufferedReader(new FileReader(filePath));
//        String s = br.readLine();
//        会出现乱码问题，所以需要转换流
//        System.out.println(s);

        String filePath = "e:\\hello.txt";
        //1.把 FileInputStream 转换成 InputStreamReader
        //2.指定编码 gbk

        //InputStreamReader isr = new InputStreamReader(new FileInputStream(filePath),"gbk");
        //BufferedReader br = new BufferedReader(isr);
        //两条语句合并
        BufferedReader br = new BufferedReader(new InputStreamReader(
                                                    new FileInputStream(filePath),"gbk"));
        System.out.println(br.readLine());
        br.close();
    }
}
